<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>busy manual page - Built-In Commands</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tk Commands</a> <small>&gt;</small> busy</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<DL>
<DD><A HREF="busy.htm#M2" NAME="L191">NAME</A>
<DL><DD>busy &mdash; confine pointer events to a window sub-tree</DD></DL>
<DD><A HREF="busy.htm#M3" NAME="L192">SYNOPSIS</A>
<DL>
</DL>
<DD><A HREF="busy.htm#M4" NAME="L193">DESCRIPTION</A>
<DD><A HREF="busy.htm#M5" NAME="L194">INTRODUCTION</A>
<DD><A HREF="busy.htm#M6" NAME="L195">EXAMPLE</A>
<DD><A HREF="busy.htm#M7" NAME="L196">OPERATIONS</A>
<DL class="operations">
<DD><A HREF="busy.htm#M8" NAME="L197"><B>tk busy </B><I>window</I> ?<I>option value</I>?...</A>
<DD><A HREF="busy.htm#M9" NAME="L198"><B>tk busy hold </B><I>window</I> ?<I>option value</I>?...</A>
<DL class="operations">
<DD><A HREF="busy.htm#M10" NAME="L199"><B>-cursor </B><I>cursorName</I></A>
</DL>
<DD><A HREF="busy.htm#M11" NAME="L200"><B>tk busy cget </B><I>window</I> <I>option</I></A>
<DD><A HREF="busy.htm#M12" NAME="L201"><B>tk busy configure </B><I>window</I> ?<I>option value</I>?...</A>
<DD><A HREF="busy.htm#M13" NAME="L202"><B>tk busy forget </B><I>window</I> ?<I>window</I>?...</A>
<DD><A HREF="busy.htm#M14" NAME="L203"><B>tk busy current </B>?<I>pattern</I>?</A>
<DD><A HREF="busy.htm#M15" NAME="L204"><B>tk busy status </B><I>window</I></A>
</DL>
<DD><A HREF="busy.htm#M16" NAME="L205">EVENT HANDLING</A>
<DD><A HREF="busy.htm#M17" NAME="L206">BINDINGS</A>
<DD><A HREF="busy.htm#M18" NAME="L207">ENTER/LEAVE EVENTS</A>
<DD><A HREF="busy.htm#M19" NAME="L208">KEYBOARD EVENTS</A>
<DD><A HREF="busy.htm#M20" NAME="L209">PORTABILITY</A>
<DD><A HREF="busy.htm#M21" NAME="L210">SEE ALSO</A>
<DD><A HREF="busy.htm#M22" NAME="L211">KEYWORDS</A>
</DL>
<H3><A NAME="M2">NAME</A></H3>
busy &mdash; confine pointer events to a window sub-tree
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>tk busy</B> <I>window </I>?<I>options</I>?<BR>
<B>tk busy hold</B> <I>window </I>?<I>options</I>?<BR>
<B>tk busy configure </B><I>window</I> ?<I>option value</I>?...<BR>
<B>tk busy forget</B> <I>window </I>?<I>window </I>?...<BR>
<B>tk busy current</B> ?<I>pattern</I>?<BR>
<B>tk busy status </B><I>window</I><BR>
<H3><A NAME="M4">DESCRIPTION</A></H3>
The <B>tk busy</B> command provides a simple means to block pointer events from
Tk widgets, while overriding the widget's cursor with a configurable busy
cursor. Note this command does not prevent keyboard events from being sent to
the widgets made busy.
<H3><A NAME="M5">INTRODUCTION</A></H3>
There are many times in applications where you want to temporarily restrict
what actions the user can take. For example, an application could have a
&ldquo;Run&rdquo;
button that when pressed causes some processing to occur. However, while the
application is busy processing, you probably don't want the user to be
able to click the
&ldquo;Run&rdquo;
button again. You may also want restrict the user from other tasks such as
clicking a
&ldquo;Print&rdquo;
button.
<P>
The <B>tk busy</B> command lets you make Tk widgets busy. This means that user
interactions such as button clicks, moving the mouse, typing at the keyboard,
etc. are ignored by the widget. You can set a special cursor (like a watch)
that overrides the widget's normal cursor, providing feedback that the
application (widget) is temporarily busy.
<P>
When a widget is made busy, the widget and all of its descendants will ignore
pointer events. It's easy to make an entire panel of widgets busy. You can
simply make the toplevel widget (such as
&ldquo;.&rdquo;)
busy. This is easier and far much more efficient than recursively traversing
the widget hierarchy, disabling each widget and re-configuring its cursor.
<P>
Often, the <B>tk busy</B> command can be used instead of Tk's <B><A HREF="../TkCmd/grab.htm">grab</A></B>
command. Unlike <B><A HREF="../TkCmd/grab.htm">grab</A></B> which restricts all user interactions to one
widget, with the <B>tk busy</B> command you can have more than one widget
active (for example, a
&ldquo;Cancel&rdquo;
dialog and a
&ldquo;Help&rdquo;
button).
<H4><A NAME="M6">EXAMPLE</A></H4>
You can make several widgets busy by simply making its ancestor widget busy
using the <B>hold</B> operation.
<P>
<PRE>frame .top
button .top.button; canvas .top.canvas
pack .top.button .top.canvas
pack .top
# . . .
<B>tk busy</B> hold .top
update</PRE>
<P>
All the widgets within <B>.top</B> (including <B>.top</B>) are now busy. Using
<B><A HREF="../TclCmd/update.htm">update</A></B> insures that <B>tk busy</B> command will take effect before any
other user events can occur.
<P>
When the application is no longer busy processing, you can allow user
interactions again and free any resources it allocated by the <B>forget</B>
operation.
<P>
<PRE><B>tk busy</B> forget .top</PRE>
<P>
The busy window has a configurable cursor. You can change the busy cursor
using the <B>configure</B> operation.
<P>
<PRE><B>tk busy</B> configure .top -cursor &quot;watch&quot;</PRE>
<P>
Destroying the widget will also clean up any resources allocated by the <B>tk
busy</B> command.
<P>
<H3><A NAME="M7">OPERATIONS</A></H3>
The following operations are available for the <B>tk busy</B> command:
<P>
<DL class="operations">
<DT><A NAME="M8"><B>tk busy </B><I>window</I> ?<I>option value</I>?...</A><DD>
Shortcut for <B>tk busy hold</B> command.
<P><DT><A NAME="M9"><B>tk busy hold </B><I>window</I> ?<I>option value</I>?...</A><DD>
Makes the specified <I>window</I> (and its descendants in the Tk window
hierarchy) appear busy. <I>Window</I> must be a valid path name of a Tk widget.
A transparent window is put in front of the specified window. This transparent
window is mapped the next time idle tasks are processed, and the specified
window and its descendants will be blocked from user interactions. Normally
<B><A HREF="../TclCmd/update.htm">update</A></B> should be called immediately afterward to insure that the hold
operation is in effect before the application starts its processing. The
following configuration options are valid:
<P>
<DL class="operations">
<DT><A NAME="M10"><B>-cursor </B><I>cursorName</I></A><DD>
Specifies the cursor to be displayed when the widget is made busy.
<I>CursorName</I> can be in any form accepted by <B><A HREF="../TkLib/GetCursor.htm">Tk_GetCursor</A></B>. The
default cursor is <B>wait</B> on Windows and <B>watch</B> on other platforms.
<P></DL>
<P><DT><A NAME="M11"><B>tk busy cget </B><I>window</I> <I>option</I></A><DD>
Queries the <B>tk busy</B> command configuration options for <I>window</I>.
<I>Window</I> must be the path name of a widget previously made busy by the
<B>hold</B> operation. The command returns the present value of the specified
<I>option</I>. <I>Option</I> may have any of the values accepted by the
<B>hold</B> operation.
<P><DT><A NAME="M12"><B>tk busy configure </B><I>window</I> ?<I>option value</I>?...</A><DD>
Queries or modifies the <B>tk busy</B> command configuration options for
<I>window</I>. <I>Window</I> must be the path name of a widget previously made
busy by the <B>hold</B> operation.  If no options are specified, a list
describing all of the available options for <I>window</I> (see
<B><A HREF="../TkLib/ConfigWidg.htm">Tk_ConfigureInfo</A></B> for information on the format of this list) is
returned. If <I>option</I> is specified with no <I>value</I>, then the command
returns a list describing the one named option (this list will be identical to
the corresponding sublist of the value returned if no <I>option</I> is
specified). If one or more <I>option-value</I> pairs are specified, then the
command modifies the given widget option(s) to have the given value(s); in
this case the command returns the empty string. <I>Option</I> may have any of
the values accepted by the <B>hold</B> operation.
<P>
Please note that the option database is referenced through <I>window</I>. For
example, if the widget <B>.frame</B> is to be made busy, the busy cursor can be
specified for it by either <B><A HREF="../TkCmd/option.htm">option</A></B> command:
<P>
<PRE>option add *frame.busyCursor gumby
option add *Frame.BusyCursor gumby</PRE>
<P><DT><A NAME="M13"><B>tk busy forget </B><I>window</I> ?<I>window</I>?...</A><DD>
Releases resources allocated by the <B>tk busy</B> command for <I>window</I>,
including the transparent window. User events will again be received by
<I>window</I>. Resources are also released when <I>window</I> is destroyed.
<I>Window</I> must be the name of a widget specified in the <B>hold</B>
operation, otherwise an error is reported.
<P><DT><A NAME="M14"><B>tk busy current </B>?<I>pattern</I>?</A><DD>
Returns the pathnames of all widgets that are currently busy. If a
<I>pattern</I> is given, only the path names of busy widgets matching
<I>pattern</I> are returned.
<P><DT><A NAME="M15"><B>tk busy status </B><I>window</I></A><DD>
Returns the status of a widget <I>window</I>. If <I>window</I> presently can not
receive user interactions, <B>1</B> is returned, otherwise <B>0</B>.
<P></DL>
<H3><A NAME="M16">EVENT HANDLING</A></H3>
<H4><A NAME="M17">BINDINGS</A></H4>
The event blocking feature is implemented by creating and mapping a
transparent window that completely covers the widget. When the busy window is
mapped, it invisibly shields the widget and its hierarchy from all events that
may be sent. Like Tk widgets, busy windows have widget names in the Tk window
hierarchy. This means that you can use the <B><A HREF="../TkCmd/bind.htm">bind</A></B> command, to handle
events in the busy window.
<P>
<PRE><B>tk busy</B> hold .frame.canvas
bind .frame.canvas_Busy &lt;Enter&gt; { ... }</PRE>
<P>
Normally the busy window is a sibling of the widget. The name of the busy
window is
&ldquo;<I>widget</I><B>_Busy</B>&rdquo;
where <I>widget</I> is the name of the widget to be made busy. In the previous
example, the pathname of the busy window is
&ldquo;<B>.frame.canvas_Busy</B>&rdquo;.
The exception is when the widget is a toplevel widget (such as
&ldquo;.&rdquo;)
where the busy window can't be made a sibling. The busy window is then a child
of the widget named
&ldquo;<I>widget</I><B>._Busy</B>&rdquo;
where <I>widget</I> is the name of the toplevel widget. In the following
example, the pathname of the busy window is
&ldquo;<B>._Busy</B>&rdquo;.
<P>
<PRE><B>tk busy</B> hold .
bind ._Busy &lt;Enter&gt; { ... }</PRE>
<H4><A NAME="M18">ENTER/LEAVE EVENTS</A></H4>
Mapping and unmapping busy windows generates Enter/Leave events for all
widgets they cover. Please note this if you are tracking Enter/Leave events in
widgets.
<H4><A NAME="M19">KEYBOARD EVENTS</A></H4>
When a widget is made busy, the widget is prevented from gaining the keyboard
focus by a user clicking on it by the busy window. But if the widget already had
focus, it still may receive keyboard events. The widget can also still receive
focus through keyboard traversal. To prevent this, you must move
focus to another window and make sure the focus can not go back to the widgets
made busy (e.g. but restricting focus to a cancel button).
<P>
<PRE>pack [frame .frame]
pack [text .frame.text]
<B>tk busy</B> hold .frame
pack [button .cancel -text &quot;Cancel&quot; -command exit]
focus .cancel
bind .cancel &lt;Tab&gt; {break}
bind .cancel &lt;Shift-Tab&gt; {break}
update</PRE>
<P>
The above example moves the focus from .frame immediately after invoking the
<B>hold</B> so that no keyboard events will be sent to <B>.frame</B> or any of
its descendants. It also makes sure it's not possible to leave button
<B>.cancel</B> using the keyboard.
<H3><A NAME="M20">PORTABILITY</A></H3>
Note that the <B>tk busy</B> command does not currently have any effect on OSX
when Tk is built using Aqua support.
<H3><A NAME="M21">SEE ALSO</A></H3>
<B><A HREF="../TkCmd/grab.htm">grab</A></B>
<H3><A NAME="M22">KEYWORDS</A></H3>
<A href="../Keywords/B.htm#busy">busy</A>, <A href="../Keywords/K.htm#keyboard events">keyboard events</A>, <A href="../Keywords/P.htm#pointer events">pointer events</A>, <A href="../Keywords/W.htm#window">window</A>
<div class="copy">Copyright &copy; 1993-1998 Lucent Technologies, Inc.
<BR>Copyright &copy; 2008 Jos Decoster
</div>
</BODY></HTML>
